<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>双条件</title>
    <script type="text/javascript">
        var typeJiaoTong='公交';
        if (typeJiaoTong=='地铁'){
            console.log('坐地铁回家')
        }else {
            console.log('坐公交回家')
        }

        var result=typeJiaoTong=='地铁'?'坐地铁回家':'坐公交回家';
        console.log(result);
    </script>
</head>
<body>

</body>
</html>